/*******************************************
Module: zt_json.c
E-Mail: 24zhutian@gmail.com
Notices: Copyright (c) 2007-2011 ls
*******************************************/
#include "zt_config.h"
#include "zt_json.h"
#include "cJSON/cJSON.h"
#include "zt_pmalloc.h"

ZT_API void zt_json_malloc_free(void *(*malloc_fn)(size_t),void (*free_fn)(void *))
{
	cJSON_Hooks hooks;

	if(malloc_fn&&free_fn){
		hooks.malloc_fn=malloc_fn;
		hooks.free_fn=free_fn;
		cJSON_InitHooks(&hooks);
	}
}

ZT_API zt_json_t* zt_json_load(const u_char *str)
{	
	return((zt_json_t *)cJSON_Parse(str));
}

ZT_API void zt_json_free(zt_json_t *json)
{
	cJSON_Delete((cJSON *)json);
}
